﻿
namespace nMongo
{
    /// <summary>
    /// Represent a static class with Object extension methods.
    /// </summary>
    public static class ObjectExtensions
    {
        /// <summary>
        /// Get the persistency state of the current object.
        /// </summary>
        /// <typeparam name="T">Type of the object.</typeparam>
        /// <param name="oneObject">Object instance.</param>
        public static MongoPersistencyState GetPersistencyState<T>(this T oneObject)
        {
            return oneObject.GetPersistencyStatistics().State;
        }

        /// <summary>
        /// Get the persistency control states for the current object.
        /// </summary>
        /// <typeparam name="T">Type of the object.</typeparam>
        /// <param name="oneObject">Object instance.</param>
        public static MongoPersistencyStatistics GetPersistencyStatistics<T>(this T oneObject)
        {
            return MongoPersistencyControlEngine.GetInstance().GetObjectPersistencyByObject(typeof(T), oneObject);
        }
    }
}
